package net.csdn.business.kanban.api.config;


import net.csdn.business.kanban.common.interceptor.impl.AtomgitInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ConditionalOnProperty(value = "service.type",havingValue = "gitcode")
public class WebConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(initGitCodeInterceptor()).addPathPatterns("/api/v1/**");
    }

    @Bean("gitCodeInterceptor")
    public AtomgitInterceptor initGitCodeInterceptor() {
        return new AtomgitInterceptor();
    }

}
